package org.libl.web.servlet.student;

import org.libl.domain.PageBean;
import org.libl.domain.Student;
import org.libl.service.student.StudentService;
import org.libl.service.student.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/student/FindPageStudentController")
public class FindPageStudentController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        //1.获取页面提交的页码数
        String strPage = request.getParameter("currentPage");
        //2.创建业务层对象,调用分页查询方法
        StudentService service = new StudentServiceImpl();
        PageBean<Student> pageBean = service.findPageByCurrentPage(
                Integer.parseInt(strPage),10);
        //3.保存到域对象,转发到分页页面显示
        request.setAttribute("pageBean",pageBean);
        request.getRequestDispatcher("/student/page.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        doPost(request, response);
    }
}
